﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.PA
{
    class Class8
    {
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Age == 18 || ppa.Age == 19 || ppa.Age == 20 || ppa.Age == 21)
            {
                da.Value = ppa.Amount * 0.3;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if ( ppa.Age == 21)
            {
                da.Value = ppa.Amount * 0.1;
                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {

            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {
                double r1 = ppa.TotalFee;
                double r2 = ppa.Amount;

                da.Value = r1 > r2 ? r1 : r2;
                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc2(IPolicyPeriodActing ppa, IDutyActing da)
        {
            

            string s = ppa.PolicyActing.Policy.SelectedColRateFactors["领取时间"];

            int a = int.Parse(s.Substring(0, 2));

            if (ppa.Age >= a && ppa.Age < 75)
            {
                da.Value = ppa.Amount * 0.2;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if ((ppa.Period + 1) % 2 == 2)
            {
                da.Value = ppa.Amount * 0.07;

            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if ((ppa.Period + 1) % 2 == 2)
            {
                da.Value = ppa.Amount * 0.07;

            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("疾病身故") && ppa.Period == 0)
            {
                da.Value = ppa.TotalFee;
                ppa.IsCurrentFinish = true;
                ppa.SchemePeriodActing.InsurantStates.Add("身故");
            }
            else if ((ppa.SchemePeriodActing.InsurantStates.Contains("疾病身故") && ppa.Period > 0) || ppa.SchemePeriodActing.InsurantStates.Contains("意外身故"))
            {

                if (ppa.Age < 70)
                {
                    da.Value = ppa.Amount * 3;
                }
                else
                {
                    da.Value = ppa.Amount * 2;
                }

                ppa.IsCurrentFinish = true;
                ppa.SchemePeriodActing.InsurantStates.Add("身故");
            }
            


        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Age == 70)
            {
                da.Value = ppa.Amount;
            }
            else if (ppa.Age == 95)
            {
                da.Value = ppa.Amount * 2;
                ppa.IsCurrentFinish = true;
            }

        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Age == 70)
            {
                da.Value = ppa.Amount * 1.7;
            }
        }

        public void calc2(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Period > 0)
            {
                double f = (double)ppa.SchemePeriodActing.SchemeActing.GetAuxConfigValue("分红率(预估)");
                IPolicyPeriodActing pppa = ppa.PolicyActing.PeriodActings[ppa.Period - 1];

                double s = pppa.GetDutyTotalValue("红利");

                da.Value = (ppa.TotalFee -ppa.Fee + s) * f;

            }
        }
    }
}
